# Django settings for amscms project.

try:
    from djangoappengine.settings_base import *
    has_djangoappengine = True
except ImportError:
    has_djangoappengine = False
    DEBUG = True
    TEMPLATE_DEBUG = DEBUG

import os
from amscms.core.utils.path import relpath


ugettext = lambda s: s
gettext = lambda s: s

SITE_ROOT = os.path.dirname(relpath(__file__))

DEBUG = True
TEMPLATE_DEBUG = DEBUG


ADMINS = (
    # ('Your Name', 'your_email@domain.com'),
)

MANAGERS = ADMINS

#DATABASES = {
#    'default': {
#        'ENGINE': 'django.db.backends.mysql', 
#        'NAME': 'amscms',                     
#        'USER': 'root',                      
#        'PASSWORD': 'root',                  
#        'HOST': '',                      
#        'PORT': '',  
#        'OPTIONS' : {
#            "init_command": "SET storage_engine=INNODB "
#        }                    
#    }
#}


# Local time zone for this installation. Choices can be found here:
# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
# although not all choices may be available on all operating systems.
# If running in a Windows environment this must be set to the same as your
# system time zone.
TIME_ZONE = 'Europe/Amsterdam'

# Language code for this installation. All choices can be found here:
# http://www.i18nguy.com/unicode/language-identifiers.html

USE_FIXED_LANGUAGE = True
LANGUAGE_CODE = 'fa'
LANGUAGES = (
    ('en', ugettext('English')),
    ('fa', ugettext('Farsi')),
)
DEFAULT_LANGUAGE = 2


SITE_ID = 1

# If you set this to False, Django will make some optimizations so as not
# to load the internationalization machinery.
USE_I18N = True

# If you set this to False, Django will not format dates, numbers and
# calendars according to the current locale
USE_L10N = True

# Login
LOGIN_URL = '/core/login'
LOGIN_REDIRECT_URL = '/'

PAGING_PAGE_SIZE = 6

# reCAPTCHA
RECAPTCHA_PRIVATE_KEY = "6Lf52rsSAAAAAEKhmH4ByRBX2PpyxRS9laNc-sr_"
RECAPTCHA_PUBLIC_KEY = "6Lf52rsSAAAAAGdFkqb06YCPH7lv6e78SYflrkNf"

# Absolute path to the directory that holds media.
# Example: "/home/media/media.lawrence.com/"
MEDIA_ROOT = os.path.join(SITE_ROOT, 'templates/static/')

# CMS
CMS_MEDIA_PATH = 'cms/'
CMS_SEO_FIELDS = True

# URL that handles the media served from MEDIA_ROOT. Make sure to use a
# trailing slash if there is a path component (optional in other cases).
# Examples: "http://media.lawrence.com", "http://example.com/media/"
MEDIA_URL = '/static/'

# URL prefix for admin media -- CSS, JavaScript and images. Make sure to use a
# trailing slash.
# Examples: "http://foo.com/media/", "/media/".
ADMIN_MEDIA_PREFIX = '/media/'

# Make this unique, and don't share it with anybody.
SECRET_KEY = 'AMSCMS _ is $ an , AMS # and ( CMS ) % web ^ application'

# List of callables that know how to import templates from various sources.
TEMPLATE_LOADERS = (
    'django.template.loaders.filesystem.Loader',
    'django.template.loaders.app_directories.Loader',
#     'django.template.loaders.eggs.Loader',
)

# Session Configuration
SESSION_COOKIE_AGE = 3600
SESSION_EXPIRE_AT_BROWSER_CLOSE = True

TEMPLATE_CONTEXT_PROCESSORS = (
    "django.contrib.auth.context_processors.auth",
    "django.core.context_processors.debug",
    "django.core.context_processors.i18n",
    "django.contrib.messages.context_processors.messages",
    "django.core.context_processors.request",
    "django.core.context_processors.media",
    
    # Facebook Open ID
    "socialauth.context_processors.facebook_api_key",
    
    # CMS
    "cms.context_processors.media",
)

MIDDLEWARE_CLASSES = (
    'django.middleware.gzip.GZipMiddleware',
    'django.middleware.common.CommonMiddleware',
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.middleware.csrf.CsrfMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    
    # Open ID
    'openid_consumer.middleware.OpenIDMiddleware',
    'amscms.core.middleware.FixedLocaleMiddleware.FixedLocaleMiddleware',
    'django.middleware.locale.LocaleMiddleware',
    'django.contrib.messages.middleware.MessageMiddleware',
    
    # Multiple Login
    'amscms.core.middleware.MultipleLoginMiddleware.MultipleLoginMiddleware',
    
    # CMS
    'cms.middleware.page.CurrentPageMiddleware',
    'cms.middleware.user.CurrentUserMiddleware',
    #'cms.middleware.multilingual.MultilingualURLMiddleware',
    'cms.middleware.media.PlaceholderMediaMiddleware',
    'amscms.ams.middleware.AdViewMiddleware.AdViewMiddleware',
    'amscms.ams.middleware.AdTagExploreMiddleware.AdTagExploreMiddleware',
)

ROOT_URLCONF = 'amscms.urls'

TEMPLATE_DIRS = (
    # Put strings here, like "/home/html/django_templates" or "C:/www/django/templates".
    # Always use forward slashes, even on Windows.
    # Don't forget to use absolute paths, not relative paths.
    os.path.join(SITE_ROOT, 'templates'),
    os.path.join(SITE_ROOT, 'ams/templates'),
    os.path.join(SITE_ROOT, 'core/templates'),
    os.path.join(SITE_ROOT, 'payment/templates'),
    os.path.join(SITE_ROOT, 'reports/templates'),
    os.path.join(SITE_ROOT, 'feeds/templates'),
    os.path.join(SITE_ROOT, 'cms/templates'),
)

# CMS
CMS_TEMPLATES = (
    ('default.html', gettext('default')),
    ('cms_template_3cols.html', gettext('3 Column Template')),
)

# TinyMCE
USE_TINYMCE = True
TINYMCE_JS_URL = '/static/js/tiny_mce/tiny_mce_src.js'
TINYMCE_DEFAULT_CONFIG = {
    #'plugins': "table,spellchecker,paste,searchreplace",
    'theme': "advanced",
}
#TINYMCE_SPELLCHECKER = True
#TINYMCE_COMPRESSOR = True



INSTALLED_APPS = (
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.sites',
    'django.contrib.auth',
    'django.contrib.messages',
    'django.contrib.admin',
    
    # Open ID
    'socialauth',
    'openid_consumer',

    
    # AMS
    'amscms.core',
    'amscms.dict',
    'amscms.ams',
    'amscms.payment',
    'amscms.reports',
    
    # TinyMCE
    'tinymce',
    
    #CMS
    'cms',
    'cms.plugins.text',
    'cms.plugins.picture',
    'cms.plugins.link',
    'cms.plugins.file',
    'cms.plugins.snippet',
    'cms.plugins.googlemap',
    'menus',
    'mptt',
    'publisher',
    
)

# djangoappengine 
if has_djangoappengine:
    INSTALLED_APPS = ('djangoappengine',) + INSTALLED_APPS
TEST_RUNNER = 'djangotoolbox.test.CapturingTestSuiteRunner'    

# Open ID settings
LOGOUT_REDIRECT_URL = '/'

try:
    from settingsopenid import *
except ImportError:
    pass
